<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>发货商：</label>
                                <input type="text" name="sysDept1"/>
                            </li>
                            <li>
                                <label>接收商：</label>
                                <input type="text" name="sysDept2"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:order:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:order:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:order:remove')}]];

        var details = [[${@permission.hasPermi('system:order:list')}]];

        var prefix = ctx + "system/order";

        let num;
        let price;
        let createTime;
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",

                modalName: "订单",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'sysDept1',
                    title: '接收商',
                    formatter: function (value, row, index) {
                        if (value == 301) {
                            return "中国石化仪征化纤股份有限公司";
                        } else if (value == 302) {
                            return "库车益泰棉业有限公司";
                        } else if (value == 303) {
                            return "鲁泰纺织有限公司";
                        } else if (value == 304) {
                            return "重庆三五三三印染服装";
                        } else if (value == 305) {
                            return "广州帝豪服装有限公司";
                        } else if (value == 306) {
                            return "雅兰迪服饰商贸有限公司";
                        } else if (value == 307) {
                            return "中国李宁有限公司";
                        } else {
                            return null;
                        }
                    }
                },
                {
                    field: 'sysDept2',
                    title: '发货商',
                    formatter: function (value, row, index) {
                        if (value == 301) {
                            return "中国石化仪征化纤股份有限公司";
                        } else if (value == 302) {
                            return "库车益泰棉业有限公司";
                        } else if (value == 303) {
                            return "鲁泰纺织有限公司";
                        } else if (value == 304) {
                            return "重庆三五三三印染服装";
                        } else if (value == 305) {
                            return "广州帝豪服装有限公司";
                        } else if (value == 306) {
                            return "雅兰迪服饰商贸有限公司";
                        } else if (value == 307) {
                            return "中国李宁有限公司";
                        } else {
                            return null;
                        }
                    }
                },
                {
                    field: 'goodsId',
                    title: '货物'
                },
                {
                    field: 'goodsNum',
                    title: '数量',
                    formatter: function (value, row, index) {
                        num = value;
                        return value;
                    }
                },
                {
                    field: 'goodsPrice',
                    title: '单价(/元)',
                    formatter: function (value, row, index) {
                        price = value;
                        return value;
                    }
                },
                {
                    field: 'goodsPrice',
                    title: '总价(/元)',
                    formatter: function (value, row, index) {
                        value = num * price;
                        return value;

                    }
                },
                {
                    field: 'myStatus',
                    title: '订单状态',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "订单已取消";
                        } else if (value == 1) {
                            return "订单已完成";
                        } else if (value == 2) {
                            return "订单正在进行中";
                        } else {
                            return null;
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        createTime = value;
                        return value;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + details + '" href="javascript:void(0)" onclick="$.operate.toDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        // actions.push('<a id="detail" class="btn btn-success btn-xs" href="javascript:void(0)"><i class="fa fa-desktop"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除记录</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


    </script>
</body>
</html>